package org.ucas.faker.web;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.ucas.faker.web.annotation.RegistryScanner;

/**
 * Created by suemi on 17-7-1.
 */
@MapperScan(basePackages = "org.ucas.faker.web.dao")
@SpringBootApplication
public class FakerMain extends SpringBootServletInitializer {
//  @Override
//  protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
//    super.configure(builder);
//    RegistryScanner.scanRegistryMethods();
//    return builder.sources(FakerMain.class);
//  }

  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    super.configure(builder);
    return super.configure(builder);
  }

  @Bean
  public EmbeddedServletContainerFactory servletContainer() {
	  TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
	  factory.setPort(18080);
	  
	  return factory;
  }
  public static void main(String[] args) {
    RegistryScanner.scanRegistryMethods();
    SpringApplication.run(FakerMain.class,args);
  }
}
